//
//  HeadlinesDetailViewController.swift
//  OverseasOnlineShopping
//
//  Created by 唐先才 on 16/3/9.
//  Copyright © 2016年 唐先才. All rights reserved.
//

import UIKit

class HeadlinesDetailViewController: BaseDetailViewController {

    var goodsIDH: String?
    var parametersH: NSDictionary?
    var pic_urlH: String?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        createData()
        self.headImage?.sd_setImageWithURL(NSURL(string: self.pic_urlH!))
    }
    
    func createData() {
        let manager = AFHTTPRequestOperationManager()
        //第一部分
        //http://mws.biyabi.com/webservice.asmx/GetInfoDetailForVideoJson
        //"http://mws.biyabi.com/webservice.asmx/GetInfoDetailForVideoJson"
        manager.POST(scroller_detail, parameters: self.parametersH, success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) -> Void in
            guard let array = responseObject as? [[String: AnyObject]] else {
                return
            }
            for dict in array {
                let model = TxcModel(dict: dict)
                self.dataArray.addObject(model)
            }
            self.createWeb()
            }) { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in
            SVProgressHUD.showErrorWithStatus(AppNetErrorTips)
        }
        //第三部分
        //http://mws.biyabi.com/webservice.asmx/GetInfoReviewWithClientLanTypeJson
        //"http://mws1.biyabi.com/webservice.asmx/GetInfoReviewWithClientLanTypeJson"
        guard let str = self.goodsIDH else {
            return
        }
        let parameters3 = ["clientLanType": "1",
            "infoID": str,
            "pageIndex": "1",
            "pageSize": "2"
        ]
        manager.POST(collectComment_url, parameters: parameters3, success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) -> Void in
            guard let array = responseObject as? [[String: AnyObject]] else {
                print("评论解包失败")
                return
            }
            for dict3 in array {
                let model = TxcModel(dict: dict3)
                self.commentDataArray.addObject(model)
            }
            }) { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in
                print("_____\(error)")
                SVProgressHUD.showErrorWithStatus(AppNetErrorTips)
        }
        
        //第四部分
        //http://mws.biyabi.com/webservice.asmx/MayLikeCatInfoListQueryJson
        //"http://mws1.biyabi.com/webservice.asmx/MayLikeCatInfoListQueryJson"
        let parameters4 = ["catUrl": "",
            "homeShow": "1",
            "infoID": str,
            "infoType": "5",
            "keyWord": "",
            "mayLikeCatCount": "4"
        ]
        manager.POST(collectLike_url, parameters: parameters4, success: { (operation: AFHTTPRequestOperation!, responseObject:AnyObject!) -> Void in
            guard let array = responseObject as? [[String: AnyObject]] else {
                print("猜你喜欢解包失败")
                return
            }
            for dict4 in array {
                let model = TxcModel(dict: dict4)
                self.likeDataArray.addObject(model)
            }
            self.tableView.reloadData()
            }) { (operation: AFHTTPRequestOperation!, error: NSError!) -> Void in
            SVProgressHUD.showErrorWithStatus(AppNetErrorTips)
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
